package Day35.listTest.Test;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * @author hyhWTX
 * @version 1.0
 * @ClassName Test01
 * @date 2022年08月05日 10:36
 * @Description: 集合类测试题练习1
 *
 * 1.1	实例化一个LinkedList集合，放入十个浮点数，使用迭代器遍历该集合输出到控制台；
 */
public class Test01 {
    public static void main(String[] args) {
        LinkedList<Float> floats = new LinkedList<>();
        floats.add((float) 1.2);
        floats.add((float) 2.2);
        floats.add((float) 3.2);
        floats.add((float) 1.23);
        floats.add((float) 5.2);
        floats.add((float) 6.2);
        floats.add((float) 1.5);
        floats.add((float) 1.8);
        floats.add((float) 9.2);
        floats.add((float) 7.2);

        for (Float o : floats) {
            System.out.println(o);
        }

        System.out.println("=====================");
        Iterator<Float> iterator = floats.iterator();
        while (iterator.hasNext()){
            Float next = iterator.next();
            System.out.println(next);
        }


        System.out.println("================");
        LinkedList<Book>  books = new LinkedList<>();
        Book book1 = new Book(1,"完美世界",10);
        Book book2 = new Book(2,"斗罗大陆1",10);
        Book book3 = new Book(3,"斗罗大陆2",10);
        Book book4 = new Book(4,"斗罗大陆3",10);
        Book book5 = new Book(5,"斗罗大陆4",10);
        Book book6 = new Book(6,"斗罗大陆5",10);
        books.add(book1);
        books.add(book2);
        books.add(book3);
        books.add(book4);
        books.add(book5);
        books.add(book6);

        for (Book book : books) {
            System.out.println(book);
        }
    }
}
